package com.baoteng.image.utils;

import android.content.Context;
import android.support.annotation.DrawableRes;

import com.baoteng.image.transformation.CoverTransformation;
import com.baoteng.image.transformation.CustomCornersTransformation;
import com.baoteng.image.transformation.PolygonTransformation;
import com.baoteng.image.transformation.ReflexBlurTransformation;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;

/**
 * Author: loren
 * Date: 2019/8/13
 * <p>
 * 获取各类Transformation
 */
public class TransformationUtils {

    /**
     * 正多边形
     */
    public static BitmapTransformation getPolygonTransformation(int edgeCount) {
        return new PolygonTransformation(edgeCount);
    }

    /**
     * 覆盖位图
     */
    public static BitmapTransformation getCoverTransformation(Context context, @DrawableRes int drawableId) {
        return new CoverTransformation(context, drawableId);
    }

    /**
     * 圆角图片倒影
     */
    public static BitmapTransformation getReflexBlurTransformation(Context context, int radius, int padding) {
        return ReflexBlurTransformation.with(context)
                .radius(radius)
                .padding(padding)
                .highlight()
                .create();
    }

    /**
     * 正方形圆角图片倒影
     */
    public static BitmapTransformation getReflexBlurTransformation(Context context, int sideLength, int radius, int padding) {
        return ReflexBlurTransformation.with(context)
                .sideLength(sideLength)
                .radius(radius)
                .padding(padding)
                .highlight()
                .border()
                .create();
    }

    /**
     * 指定位置圆角图片
     */
    public static BitmapTransformation getCustomCornersTransformation(float radius, CustomCornersTransformation.CornerType cornerType) {
        return new CustomCornersTransformation(radius, cornerType);
    }

}
